package com.itheima.test.test3;

public class girlFriend {
    //属性
    private String name;
    private int age;
    String gender;

    //针对每个私有化成员变量，都要提供getter/setter方法
    //给成员变量进行赋值
    public void setName(String n){
        name = n;
    }
    //对外提供返回值
    public String getName(){
        return name;
    }

    public void setAge(int a){
        if(a>=18&&a<=50){
            age = a;
        }else{
            System.out.println("年龄不合法");
        }
    }
    public int getAge(){
        return age;
    }


    //行为
    public void sleep(){
        System.out.println("女朋友在睡觉");
    }

    public void eat(){
        System.out.println("女朋友在吃饭");
    }
}

//private是成员修饰符
//private修饰的成员变量，只能在本类中访问
